package com.hsnn.medstgmini.pro.base.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.hsnn.medstgmini.Constants;
import com.hsnn.medstgmini.util.DicSysUtil;
import com.hsnn.medstgmini.util.ParseNumber;

/**
 * ViewGoods entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "view_goods")
public class ViewGoods implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 590462263563749372L;
	private String goodsCode;// 商品号
	private String projId;// 所属项目
	private String projName;// 项目名称
	private String drugId;// 药品ID
	private String drugName;// 通用名
	private String drugNameSpel;
	private String formName;// 剂型名称
	private String specName;// 规格
	private Integer factor;// 转换系数
	private String unit;// 包装单位
	private String prodCompId;// 生产企业id
	private String prodComp;// 企业名称
	private String compSpelCode;
	private String drugCat;// 药品分类
	private String drugCatText;// 药品分类名称
	private Double proPriceLimit;// 采购限价
	private String proPriceLimitStr = "0.00"; // 采购限价保留两位小数
	private Double retailPriceLimit;// 最高零售限价
	private String retailPriceLimitStr = "0.00"; // 最高零售限价保留两位小数
	private String drugCode;          // 药品编码
	private Short drugStatus;         // 药品状态 0停用1启用
	private String materialName;	//	材质
	private Short goodsStatus;        // 商品状态 0停用1启用
	private Short projStatus;         // 商品所在项目状态 0停用1启用
	
	public ViewGoods() {

	}

	/** full constructor */
	public ViewGoods(String goodsCode, String projId, String projName,
			String drugId, String drugName, String formName, String specName,
			Integer factor, String unit, String prodCompId, String prodComp,
			String drugCat, Double proPriceLimit, Double retailPriceLimit,
			String drugCode, Short drugStatus, String compSpelCode, String drugNameSpel) {
		this.goodsCode = goodsCode;
		this.projId = projId;
		this.projName = projName;
		this.drugId = drugId;
		this.drugName = drugName;
		this.formName = formName;
		this.specName = specName;
		this.factor = factor;
		this.unit = unit;
		this.prodCompId = prodCompId;
		this.prodComp = prodComp;
		this.drugCat = drugCat;
		this.proPriceLimit = proPriceLimit;
		this.retailPriceLimit = retailPriceLimit;
		this.drugCode = drugCode;
		this.drugStatus = drugStatus;
		this.compSpelCode = compSpelCode;
		this.drugNameSpel = drugNameSpel;
	}

	// Property accessors
	@Column(name = "proj_id", length = 256)
	public String getProjId() {
		return projId;
	}

	public void setProjId(String projId) {
		this.projId = projId;
	}

	@Column(name = "goods_code", nullable = false, length = 36)
	@Id
	public String getGoodsCode() {
		return this.goodsCode;
	}

	public void setGoodsCode(String goodsCode) {
		this.goodsCode = goodsCode;
	}

	@Column(name = "proj_name", length = 256)
	public String getProjName() {
		return this.projName;
	}

	public void setProjName(String projName) {
		this.projName = projName;
	}

	@Column(name = "drug_id", length = 36)
	public String getDrugId() {
		return this.drugId;
	}

	public void setDrugId(String drugId) {
		this.drugId = drugId;
	}

	@Column(name = "drug_name", length = 512)
	public String getDrugName() {
		return this.drugName;
	}

	public void setDrugName(String drugName) {
		this.drugName = drugName;
	}

	@Column(name = "form_name", length = 100)
	public String getFormName() {
		return this.formName;
	}

	public void setFormName(String formName) {
		this.formName = formName;
	}

	@Column(name = "prod_comp_id", length = 36)
	public String getProdCompId() {
		return prodCompId;
	}

	public void setProdCompId(String prodCompId) {
		this.prodCompId = prodCompId;
	}

	@Column(name = "spec_name", length = 100)
	public String getSpecName() {
		return this.specName;
	}

	public void setSpecName(String specName) {
		this.specName = specName;
	}

	@Column(name = "factor")
	public Integer getFactor() {
		return this.factor;
	}

	public void setFactor(Integer factor) {
		this.factor = factor;
	}

	@Column(name = "unit", length = 36)
	public String getUnit() {
		return this.unit;
	}

	public void setUnit(String unit) {
		this.unit = unit;
	}

	@Column(name = "prod_comp", length = 512)
	public String getProdComp() {
		return this.prodComp;
	}

	public void setProdComp(String prodComp) {
		this.prodComp = prodComp;
	}

	@Column(name = "drug_cat", length = 128)
	public String getDrugCat() {
		return this.drugCat;
	}

	public void setDrugCat(String drugCat) {
		this.drugCat = drugCat;
	}

	@Column(name = "pro_price_limit", precision = 18, scale = 3)
	public Double getProPriceLimit() {
		return this.proPriceLimit;
	}

	public void setProPriceLimit(Double proPriceLimit) {
		this.proPriceLimit = proPriceLimit;
	}

	@Transient
	public String getProPriceLimitStr() {
		if (proPriceLimit != null) {
			proPriceLimitStr = ParseNumber.toStrDecimal(proPriceLimit);
		}
		return proPriceLimitStr;
	}

	public void setProPriceLimitStr(String proPriceLimitStr) {
		this.proPriceLimitStr = proPriceLimitStr;
	}

	@Transient
	public String getRetailPriceLimitStr() {
		if (retailPriceLimit != null) {
			retailPriceLimitStr = ParseNumber.toStrDecimal(retailPriceLimit);
		}
		return retailPriceLimitStr;
	}

	public void setRetailPriceLimitStr(String retailPriceLimitStr) {
		this.retailPriceLimitStr = retailPriceLimitStr;
	}

	@Column(name = "retail_price_limit", precision = 18, scale = 3)
	public Double getRetailPriceLimit() {
		return this.retailPriceLimit;
	}

	public void setRetailPriceLimit(Double retailPriceLimit) {
		this.retailPriceLimit = retailPriceLimit;
	}

	@Column(name = "drug_code", length = 100)
	public String getDrugCode() {
		return this.drugCode;
	}

	public void setDrugCode(String drugCode) {
		this.drugCode = drugCode;
	}

	@Column(name = "goods_status")
	public Short getGoodsStatus() {
		return this.goodsStatus;
	}

	public void setGoodsStatus(Short goodsStatus) {
		this.goodsStatus = goodsStatus;
	}
	
	@Column(name = "drug_status")
    public Short getDrugStatus() {
    	return this.drugStatus;
    }
    
	public void setDrugStatus(Short drugStatus) {
		this.drugStatus = drugStatus;
	}
	
	@Column(name = "proj_status")
    public Short getProjStatus() {
    	return this.projStatus;
    }
    
	public void setProjStatus(Short projStatus) {
		this.projStatus = projStatus;
	}
	
	@Column(name = "material_name")
	public String getMaterialName() {
		return materialName;
	}

	public void setMaterialName(String materialName) {
		this.materialName = materialName;
	}

	@Column(name = "comp_spel_code")
	public String getCompSpelCode() {
		return compSpelCode;
	}

	public void setCompSpelCode(String compSpelCode) {
		this.compSpelCode = compSpelCode;
	}
	
	@Column(name = "drug_name_spel")
	public String getDrugNameSpel() {
		return drugNameSpel;
	}

	public void setDrugNameSpel(String drugNameSpel) {
		this.drugNameSpel = drugNameSpel;
	}
	
	@Transient
	public String getDrugCatText() {
		
		if (drugCatText == null) {
			drugCatText = DicSysUtil.getValueByClassCodeAndDicCode(Constants.DRUG_CAT, drugCat);
		}
		return this.drugCatText;
	}
	
	public void setDrugCatText(String drugCatText) {
		this.drugCatText = drugCatText;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((drugCat == null) ? 0 : drugCat.hashCode());
		result = prime * result
				+ ((drugCode == null) ? 0 : drugCode.hashCode());
		result = prime * result + ((drugId == null) ? 0 : drugId.hashCode());
		result = prime * result
				+ ((drugName == null) ? 0 : drugName.hashCode());
		result = prime * result
				+ ((drugStatus == null) ? 0 : drugStatus.hashCode());
		result = prime * result + ((factor == null) ? 0 : factor.hashCode());
		result = prime * result
				+ ((formName == null) ? 0 : formName.hashCode());
		result = prime * result
				+ ((goodsCode == null) ? 0 : goodsCode.hashCode());
		result = prime * result
				+ ((goodsStatus == null) ? 0 : goodsStatus.hashCode());
		result = prime * result
				+ ((materialName == null) ? 0 : materialName.hashCode());
		result = prime * result
				+ ((proPriceLimit == null) ? 0 : proPriceLimit.hashCode());
		result = prime
				* result
				+ ((proPriceLimitStr == null) ? 0 : proPriceLimitStr.hashCode());
		result = prime * result
				+ ((prodComp == null) ? 0 : prodComp.hashCode());
		result = prime * result
				+ ((prodCompId == null) ? 0 : prodCompId.hashCode());
		result = prime * result + ((projId == null) ? 0 : projId.hashCode());
		result = prime * result
				+ ((projName == null) ? 0 : projName.hashCode());
		result = prime * result
				+ ((projStatus == null) ? 0 : projStatus.hashCode());
		result = prime
				* result
				+ ((retailPriceLimit == null) ? 0 : retailPriceLimit.hashCode());
		result = prime
				* result
				+ ((retailPriceLimitStr == null) ? 0 : retailPriceLimitStr
						.hashCode());
		result = prime * result
				+ ((specName == null) ? 0 : specName.hashCode());
		result = prime * result + ((unit == null) ? 0 : unit.hashCode());
		result = prime * result + ((compSpelCode == null) ? 0 : compSpelCode.hashCode());
		result = prime * result + ((drugNameSpel == null) ? 0 : drugNameSpel.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ViewGoods other = (ViewGoods) obj;
		if (drugCat == null) {
			if (other.drugCat != null)
				return false;
		} else if (!drugCat.equals(other.drugCat))
			return false;
		if (drugCode == null) {
			if (other.drugCode != null)
				return false;
		} else if (!drugCode.equals(other.drugCode))
			return false;
		if (drugId == null) {
			if (other.drugId != null)
				return false;
		} else if (!drugId.equals(other.drugId))
			return false;
		if (drugName == null) {
			if (other.drugName != null)
				return false;
		} else if (!drugName.equals(other.drugName))
			return false;
		if (drugStatus == null) {
			if (other.drugStatus != null)
				return false;
		} else if (!drugStatus.equals(other.drugStatus))
			return false;
		if (factor == null) {
			if (other.factor != null)
				return false;
		} else if (!factor.equals(other.factor))
			return false;
		if (formName == null) {
			if (other.formName != null)
				return false;
		} else if (!formName.equals(other.formName))
			return false;
		if (goodsCode == null) {
			if (other.goodsCode != null)
				return false;
		} else if (!goodsCode.equals(other.goodsCode))
			return false;
		if (goodsStatus == null) {
			if (other.goodsStatus != null)
				return false;
		} else if (!goodsStatus.equals(other.goodsStatus))
			return false;
		if (materialName == null) {
			if (other.materialName != null)
				return false;
		} else if (!materialName.equals(other.materialName))
			return false;
		if (proPriceLimit == null) {
			if (other.proPriceLimit != null)
				return false;
		} else if (!proPriceLimit.equals(other.proPriceLimit))
			return false;
		if (proPriceLimitStr == null) {
			if (other.proPriceLimitStr != null)
				return false;
		} else if (!proPriceLimitStr.equals(other.proPriceLimitStr))
			return false;
		if (prodComp == null) {
			if (other.prodComp != null)
				return false;
		} else if (!prodComp.equals(other.prodComp))
			return false;
		if (prodCompId == null) {
			if (other.prodCompId != null)
				return false;
		} else if (!prodCompId.equals(other.prodCompId))
			return false;
		if (projId == null) {
			if (other.projId != null)
				return false;
		} else if (!projId.equals(other.projId))
			return false;
		if (projName == null) {
			if (other.projName != null)
				return false;
		} else if (!projName.equals(other.projName))
			return false;
		if (projStatus == null) {
			if (other.projStatus != null)
				return false;
		} else if (!projStatus.equals(other.projStatus))
			return false;
		if (retailPriceLimit == null) {
			if (other.retailPriceLimit != null)
				return false;
		} else if (!retailPriceLimit.equals(other.retailPriceLimit))
			return false;
		if (retailPriceLimitStr == null) {
			if (other.retailPriceLimitStr != null)
				return false;
		} else if (!retailPriceLimitStr.equals(other.retailPriceLimitStr))
			return false;
		if (specName == null) {
			if (other.specName != null)
				return false;
		} else if (!specName.equals(other.specName))
			return false;
		if (unit == null) {
			if (other.unit != null)
				return false;
		} else if (!unit.equals(other.unit))
			return false;
		if (compSpelCode == null) {
			if (other.compSpelCode != null)
				return false;
		} else if (!compSpelCode.equals(other.compSpelCode))
			return false;
		if (drugNameSpel == null) {
			if (other.drugNameSpel != null)
				return false;
		} else if (!drugNameSpel.equals(other.drugNameSpel))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "ViewGoods [goodsCode=" + goodsCode + ", projId=" + projId
				+ ", projName=" + projName + ", drugId=" + drugId
				+ ", drugName=" + drugName + ", drugNameSpel=" + drugNameSpel
				+ ", formName=" + formName + ", specName=" + specName
				+ ", factor=" + factor + ", unit=" + unit + ", prodCompId="
				+ prodCompId + ", prodComp=" + prodComp + ", compSpelCode="
				+ compSpelCode + ", drugCat=" + drugCat + ", drugCatText="
				+ drugCatText + ", proPriceLimit=" + proPriceLimit
				+ ", proPriceLimitStr=" + proPriceLimitStr
				+ ", retailPriceLimit=" + retailPriceLimit
				+ ", retailPriceLimitStr=" + retailPriceLimitStr
				+ ", drugCode=" + drugCode + ", drugStatus=" + drugStatus
				+ ", materialName=" + materialName + ", goodsStatus="
				+ goodsStatus + ", projStatus=" + projStatus + "]";
	}
}